home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / doslynx / src / tdoslyn7.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  5.6 KB  |  216 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TDosLynx : public TApplication
  4. //    Include File:    TDosLynx.h
  5. //    Purpose:    Implement our application object.
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-09-93    created
  9. //        02-09-94    Split all members into seperate files to
  10. //                enhance overlay support.
  11. #define Uses_TDeskTop
  12. #define Uses_TVMemMgr
  13. #define Uses_MsgBox
  14. #include"tdoslynx.h"
  15. #include"globals.h"
  16. #include<stdlib.h>
  17.  
  18. extern "C"    {
  19. #include"..\wattcp\include\tcp.h"
  20. #include"image.h"
  21. };
  22.  
  23. void TDosLynx::handleEvent(TEvent& TE_Event)    {
  24. //    Purpose:    Determine the implications of an event
  25. //    Arguments:    TE_Event    What happened for call to function
  26. //    Return Value:   void
  27. //    Remarks/Portability/Dependencies/Restrictions:
  28. //    Revision History:
  29. //        12-13-93    created
  30. //        03-31-94    Modified to better handle an ownerClose
  31. //                request.  Didn't work.
  32. //        04-05-94    Video switching mode code added.  Moved into
  33. //                a separate function.
  34.  
  35.     //    If the following is not null, a window is requesting that
  36.     //    it be close.  Will do so now to avoid a particular problem
  37.     //    of returning to an object that no longer exists.
  38.     if(TVp_ToBeRemoved != NULL)    {
  39.         deskTop->remove(TVp_ToBeRemoved);
  40.         destroy(TVp_ToBeRemoved);
  41.         TVp_ToBeRemoved = NULL;
  42.     }
  43.  
  44.     //    If the following is not null, then there is an image that
  45.     //    we must view.  Will do so now.  This is a staggered event.
  46.     if(cp_ToBeViewed != NULL)    {
  47.         if(usi_graphicsmode != (image_modes)image_modes_total)    {
  48.             //    Suspend DosLynx and view the image.
  49.             suspend();
  50.             ::image_viewer(cp_ToBeViewed, (image_modes)
  51.                 usi_graphicsmode);
  52.             resume();
  53.             redraw();
  54.         }
  55.         delete(cp_ToBeViewed);
  56.         cp_ToBeViewed = NULL;
  57.     }
  58.  
  59.     if(TE_Event.what & evMessage)    {
  60.         switch(TE_Event.message.command)    {
  61.         case cmOpenURL:
  62.             //    Open a URL
  63.             OpenURL();
  64.             clearEvent(TE_Event);
  65.             break;
  66.         case cmUnHideMessage:
  67.             //    Show the message window.
  68.             ::TC->show();
  69.             ::TC->makeFirst();
  70.             clearEvent(TE_Event);
  71.             break;
  72.         case cmTile:
  73.             //    Tile all windows on desktop.
  74.             ::TC->hide();
  75.             deskTop->tile(deskTop->getExtent());
  76.             clearEvent(TE_Event);
  77.             break;
  78.         case cmCascade:
  79.             //    Cascade all windows on desktop.
  80.             ::TC->hide();
  81.             deskTop->cascade(deskTop->getExtent());
  82.             clearEvent(TE_Event);
  83.             break;
  84.         case cmDosShell:
  85.             //    Provide a dos shell.
  86.             suspend();
  87.             system("cls");
  88.             system("echo Type EXIT to return to DOSLYNX.");
  89.             system(getenv("COMSPEC") == NULL ? "command.com" :
  90.                 getenv("COMSPEC"));
  91.             resume();
  92.             clearEvent(TE_Event);
  93.             redraw();
  94.             break;
  95. #ifndef RELEASE
  96.         case cmTraceWWW:    {
  97.             //    Turn on WWW tracing.
  98.             extern int WWW_TraceFlag;
  99.             WWW_TraceFlag++;
  100.             WWW_TraceFlag %= 2;
  101.             clearEvent(TE_Event);
  102.             doslynxmessage("WWW tracing turned " << (WWW_TraceFlag
  103.                 == 1 ? "on" : "off") << '.');
  104.             break;
  105.         }
  106.         case cmTraceWATTCP:    {
  107.             //    Turn on Wattcp debugging.
  108.             static int i_twattcp = 0;
  109.             i_twattcp++;
  110.             i_twattcp %= 2;
  111.             tcp_set_debug_state(i_twattcp);
  112.             clearEvent(TE_Event);
  113.             doslynxmessage("WATTCP tracing turned " << (i_twattcp
  114.                 == 1 ? "on" : "off") << '.');
  115.             break;
  116.         }
  117.         case cmTraceDOSLYNX:    {
  118.             //    Turn on doslynx debugging.
  119.             c_trace++;
  120.             c_trace %= 2;
  121.             clearEvent(TE_Event);
  122.             doslynxmessage("DOSLYNX tracing turned " << (c_trace
  123.                 == 1 ? "on" : "off") << '.');
  124.             break;
  125.         }
  126. #endif // RELEASE
  127.         case cmOpenLocal:
  128.             //    Open a local file
  129.             OpenLocal();
  130.             clearEvent(TE_Event);
  131.             break;
  132.         case cmOwnerClose:
  133.             //    Destroy the requesting view.
  134.             //    Assume deskTop owns the view.
  135.             //    Here's the kludge, set a variable that will
  136.             //    close this for us the next time the function
  137.             //    is called so that we will avoid returning to
  138.             //    an object that no longer exists.
  139.             TVp_ToBeRemoved = (TView *)(TE_Event.message.infoPtr);
  140.             clearEvent(TE_Event);
  141.             break;
  142.         case cmQuit:    {
  143.             //    The application is about to exit.
  144.             //    Broadcast to all open views in the desktop
  145.             //    to close.
  146.             //    Don't clear this event.  The base class will
  147.             //    have to do its wrap up also.
  148.             TEvent TE_close;
  149.             TE_close.what = evBroadcast;
  150.             TE_close.message.command = cmClose;
  151.             deskTop->handleEvent(TE_close);
  152.             break;
  153.         }
  154.         case cmVideoMode:    {
  155.             //    Change the video mode from what we are to
  156.             //    the other....
  157.             switchVideo();
  158.             clearEvent(TE_Event);
  159.             break;
  160.         }
  161.         case cmMailDeveloper:    {
  162.             mailDeveloper();
  163.             clearEvent(TE_Event);
  164.             break;
  165.         }
  166.         case cmImage:    {
  167.             //    There is an image that we will view.
  168.             cp_ToBeViewed = (char *)TE_Event.message.infoPtr;
  169.             clearEvent(TE_Event);
  170.             break;
  171.         }
  172.         case cmHomePage:    {
  173.             //    Load up the home page.
  174.             if(cp_Home != NULL)    {
  175.                 OpenURL(cp_Home);
  176.             }
  177.             else    {
  178.                 doslynxmessage("home not specified in the"
  179.                     "configuration file.");
  180.             }
  181.             clearEvent(TE_Event);
  182.             break;
  183.         }
  184.         case cmHotList:    {
  185.             //    Load up the HotList.
  186.             if(cp_HotList != NULL)    {
  187.                 OpenLocal(cp_HotList);
  188.             }
  189.             else    {
  190.                 doslynxmessage("hotlistfile not specified in "
  191.                     "the configuration file.");
  192.             }
  193.             clearEvent(TE_Event);
  194.             break;
  195.         }
  196.         case cmAboutDosLynx:    {
  197.             auto TRect TR_about = deskTop->getExtent();
  198.             TR_about.grow(-3, -1 * TR_about.b.y / 2);
  199.             TR_about.grow(0, 6);
  200.  
  201.             messageBoxRect(TR_about, "\nDosLynx\nVersion 0.71 "
  202.                 "Alpha\nCopyright (c) 1994 by The "
  203.                 "University of Kansas, All Rights Reserved\n"
  204.                 "Developer:  Garrett Arch Blythe",
  205.                 mfInformation | mfOKButton);
  206.             break;
  207.         }
  208.         default:
  209.             //    Event not handled here.
  210.             break;
  211.         }
  212.     }
  213.  
  214.     //    Have our base handle the event also.
  215.     TApplication::handleEvent(TE_Event);
  216. }